import { Component, OnInit, Input } from '@angular/core';
import { PromptService } from './prompt.service';
import { OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks';
import { Subscription } from 'rxjs';

@Component({
  selector: 'app-prompt',
  templateUrl: './prompt.component.html',
  styleUrls: ['./prompt.component.css']
})
export class PromptComponent implements OnInit {
  
  @Input()
  getResult : object|string;
  
  whichStyle : object;	

  public promptSubscription:Subscription;
  
  constructor(private promptService:PromptService) {}

  ngOnInit() {
	  this.promptService.getPrompt().subscribe((msg:any)=>{
			this.getResult = msg;
			this.onOff();
	  })
  }
  

  // 显示（隐藏）
  onOff() {
  	
  	this.whichStyle = {
		'c-message'   	   	: true,
		'c-message--close' 	: false,
		'messageFadeOutUp'	: false,
		'messageFadeInDown'	: true,
	}

  	setTimeout(()=> {
  		this.whichStyle = {
  			'c-message'   	   	: true,
  			'c-message--close' 	: false,
  			'messageFadeOutUp'	: true,
  			'messageFadeInDown'	: false,
  		}
  	},2100);

  }

}
